package com.ams.thread.lesson7;

import lombok.extern.slf4j.Slf4j;

import java.util.Locale;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author： 乐哥聊编程(全平台同号)
 */
@Slf4j
public class Example18 {
    private static ReentrantLock lock = new ReentrantLock();
    public static void main(String[] args) {
        new Thread(new Thread1()).start();
    }

    static class Thread1 implements Runnable {

        @Override
        public void run() {
            lock.lock();
            lock.lock();
            log.info("获取到重入锁");
            lock.unlock();
            lock.unlock();
            log.info("释放了所有锁");
        }
    }
}
